This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
library(sf)
## Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.3 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 2.0.1 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggspatial)
library(ggthemes)
public <- st_read("https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/Privately_Owned_Public_Spaces/FeatureServer/0/query?where=1=1&outFields=*&outSR=4326&f=pgeojson")
## Reading layer `OGRGeoJSON' from data source
## `https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/Privately_Owned_Public_Spaces/FeatureServer/0/query?where=1=1&outFields=*&outSR=4326&f=pgeojson'
## using driver `GeoJSON'
## Simple feature collection with 388 features and 34 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -74.13974 ymin: 40.57282 xmax: -73.75302 ymax: 40.83362
## Geodetic CRS: WGS 84
nhoods <- st_read("https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/NYC_Neighborhood_Tabulation_Areas_2020/FeatureServer/0/query?where=1=1&outFields=*&outSR=4326&f=pgeojson")
## Reading layer `OGRGeoJSON' from data source
## `https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/NYC_Neighborhood_Tabulation_Areas_2020/FeatureServer/0/query?where=1=1&outFields=*&outSR=4326&f=pgeojson'
## using driver `GeoJSON'
## Simple feature collection with 262 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -74.25559 ymin: 40.49612 xmax: -73.70001 ymax: 40.91554
## Geodetic CRS: WGS 84
health <- st_read("https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/NYC_Health_Centers/FeatureServer/0/query?where=1=1&outFields=*&outSR=4326&f=pgeojson")
## Reading layer `OGRGeoJSON' from data source
## `https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/NYC_Health_Centers/FeatureServer/0/query?where=1=1&outFields=*&outSR=4326&f=pgeojson'
## using driver `GeoJSON'
## Simple feature collection with 30 features and 6 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -74.25559 ymin: 40.49612 xmax: -73.70001 ymax: 40.91554
## Geodetic CRS: WGS 84
ggplot(public) +
annotation_map_tile(zoomin = 0, progress = "none", type = "hotstyle") +
geom_sf() +
labs(caption = "Map tiles and data by OpenStreetMap")
## Loading required namespace: raster
ggplot() +
geom_sf(data = nhoods, color = "NA", alpha = 0.5,
aes(fill = "NYC Neighborhoods")) +
geom_sf(data = public, color = "blue") +
scale_fill_manual(values = "black", name = "")
ggplot() +
ggtitle("NYC Neighborhoods") +
annotation_map_tile(zoomin = 0, progress = "none", type = "cartolight") +
geom_sf(data = nhoods, color = "white", alpha = 0.5,
aes(fill = "NYC Neighborhoods")) +
geom_sf(data = public,
aes(color = "Privately Owned Public Spaces")) +
scale_fill_manual(values = "black", name = "") +
scale_color_manual(values = c("blue"), name = "") +
labs(caption = "Privately Owned Public Spaces in New York City")
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "cartolight") +
geom_sf(data = health, color = "NA", alpha = 0.5,
aes(fill = "NYC Neighborhoods")) +
geom_sf(data = public,
aes(color = "Privately Owned Public Spaces")) +
scale_fill_manual(values = "black", name = "") +
scale_color_manual(values = c("blue"), name = "") +
labs(caption = "Privately Owned Public Spaces in New York City")
draftmap_plot
pdf(“A1_draft.pdf”, width = 5, height = 3) draftmap_plot dev.off()
pdf(“A1big_draft.pdf”, width = 10, height = 6) draftmap_plot dev.off()